<template>
  <el-dialog :visible.sync="visible" v-dialogDrag title="人员选择" :close-on-click-modal="false" class="tl-dialog" width="500px" :append-to-body="true" :modal-append-to-body="true" @open="open" @close="close">
    <el-form class="tl-form" ref="form" :model="model" size="small" label-width="90px">
      <el-row>
        <el-col :span="24">
          <el-form-item label="按人员选择">
            <tl-ref-user v-model="model.usercodes" :initDisplayData.sync="model.usernames" dataType="code" :singleSelect="false"></tl-ref-user>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="按部门选择">
            <tl-ref-dept v-model="model.deptcodes" :initDisplayData.sync="model.deptnames" nameType="fullname" dataType="code" :singleSelect="false"></tl-ref-dept>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="按团队选择">
            <tl-ref-list v-model="model.teamids" :initDisplayData.sync="model.teamnames" refTitle="选择团队" :queryDataUrl="url.queryTeamList" :singleSelect="false"></tl-ref-list>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="按角色选择">
            <tl-ref-role v-model="model.roleids" :initDisplayData.sync="model.rolenames" dataType="id" :singleSelect="false"></tl-ref-role>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="text" @click="doCancelEdit">取消</el-button>
      <el-button type="primary" @click="doSubmitEdit">确认</el-button>
    </div>
  </el-dialog>
</template>

<script>
/** mixins */
/** 子组件 */
/** 工具类 */
import { putAction, getAction, postAction, deleteAction } from '@tapui/utils/http'
/** VUE配置 */
export default {
  name: 'TlMulitUserSelect',
  components: {},
  data() {
    return {
      url: {
        queryTeamList: 'base/teamInfo/list' // 查询团队
      },
      visible: false,
      model: {
        usernames: '',
        usercodes: '',
        deptnames: '',
        deptcodes: '',
        teamids: '',
        teamnames: '',
        roleids: '',
        rolenames: ''
      }
    }
  },
  props: {
    value: {
      type: Object,
      default: function() {
        return {
          usernames: '',
          usercodes: '',
          deptnames: '',
          deptcodes: '',
          teamids: '',
          teamnames: '',
          roleids: '',
          rolenames: ''
        }
      }
    }
  },
  methods: {
    open() {
      // 页面加载完毕执行
      this.model = this.value
    },
    doSubmitEdit() {
      this.value = this.model
      this.$emit('confirm', this.model)
      this.visible = false
    },
    doCancelEdit() {
      this.visible = false
    },
    close() {}
  }
}
</script>
